package com.rural.bus.model;

import java.io.Serializable;

import com.baidu.mapapi.search.core.PoiInfo;

public class MyPoiInfo implements Serializable, Comparable<MyPoiInfo> {

	private static final long serialVersionUID = 3989233846831641208L;
	public String id;
	public double latitude;
	public double longitude;
	public String address;
	public String name;
	
	public MyPoiInfo(double latitude, double longitude, String address, String name) {
		this.latitude = latitude;
		this.longitude = longitude;
		this.address = address;
		this.name = name;
	}
	
	public MyPoiInfo(){
		
	}
	
	public static MyPoiInfo parsePoi(PoiInfo info) {
		MyPoiInfo address = null;
		if (info.location != null) {
			address = new MyPoiInfo();
			address.name = info.name;
			address.address = info.address;
			address.latitude = info.location.latitude;
			address.longitude = info.location.longitude;
		}
		return address;
	}
	
	@Override
	public int compareTo(MyPoiInfo arg0) {
		if (this.name.equals(arg0.name)) {
			return 0;
		} else {
			return 1;
		}
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		MyPoiInfo other = (MyPoiInfo) obj;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}
}
